package com.hmsm.server.util;

import java.text.SimpleDateFormat;

import org.apache.commons.lang.StringUtils;

public class GenerateDossierNo {
	public static int index = 1;
	public static String currTimeStr = "";
	
	public static String getTimeMillisSequence() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		String timeStr = sdf.format(System.currentTimeMillis());
		
		StringBuffer sb = new StringBuffer();
		sb.append(timeStr);
		sb.append("-");
		if(StringUtils.equals(currTimeStr, timeStr)){
			if(index > 9999){
				index = 1;
			}
		}else{
			index = 1;
			currTimeStr = timeStr;
		}
		int length = (index + "").length();
		for (int i = 0; i < 4 - length; i++) {
			sb.append("0");
		}
		sb.append(index);
		index ++;
		return sb.toString();
	}

	public static void main(String[] args) {
		System.out.println(getTimeMillisSequence());
	}
}
